//
//  LCSendVoiceCell.m
//  安好医生端
//
//  Created by 付国强 on 14-8-15.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "LCSendVoiceCell.h"

@implementation LCSendVoiceCell
{
    NSTimer *timer;
    NSMutableArray *imageArray1;
    NSMutableArray *imageArray2;
    NSInteger key;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //头像
        self.iconImageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 53,60)];
        [self.contentView addSubview:self.iconImageView];

        //聊天文字图片语音背景
        self.backImage=[[UIImageView alloc] initWithFrame:CGRectZero];
        self.backImage.userInteractionEnabled=YES;
        [self.contentView addSubview:self.backImage];
        //录音时长
        self.timeLenth=[[UILabel alloc] initWithFrame:CGRectMake(5, 5, 10, 10)];
        [self.contentView addSubview:self.timeLenth];
        self.timeLenth.font=[UIFont systemFontOfSize:14];
        self.timeLenth.backgroundColor=[UIColor clearColor];
        self.voiceImage=[[UIImageView alloc]initWithFrame:CGRectZero];
        [self.contentView addSubview:self.voiceImage];
        
        //播放按钮
        self.playButton=[UIButton buttonWithType:UIButtonTypeCustom];
        self.playButton.frame=CGRectZero;
        [self.playButton addTarget:self action:@selector(doplay:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.playButton];
        self.voiceData=[[NSData alloc] init];
    }
    return self;
}
- (void)doplay:(UIButton * )btn
{
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(dokill) name:@"kill" object:nil];
    if ([self.voiceImage isAnimating]) {
        [self.voiceImage stopAnimating];
    }
    if (self.delegate&&[self.delegate respondsToSelector:@selector(playVoice:withIntiger:)]) {
        [self.delegate playVoice:self.voiceData withIntiger:self.tag];
    }
}
- (void)dokill
{
    [self.voiceImage stopAnimating];
}
- (void)transfer:(NSData *)data
{
    self.voiceData=data;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
